package com.qiyun.dinghuohui.utils;

import com.qiyun.dinghuohui.common.CommonDataSets;
import com.qiyun.dinghuohui.vo.SX_Info;

import java.util.Comparator;

public class ZHDHDataByCode implements Comparator<SX_Info> {

	private int px_flag = 0;

	public ZHDHDataByCode() {
	};

	public ZHDHDataByCode(int px_flag) {
		this.px_flag = px_flag;
	}

	@Override
	public int compare(SX_Info lhs, SX_Info rhs) {
		try
		{
			switch (px_flag)
			{
			case 0:
				int code1 = CommonDataSets.getIntforString(lhs.getCode());
				int code2 = CommonDataSets.getIntforString(rhs.getCode());
				if (code1 > code2)
				{
					return 1;
				} else if (code1 < code2)
				{
					return -1;
				} else
				{
					return 0;
				}
			case 1:
				int num1 = lhs.getMaxNum();
				int num2 = rhs.getMaxNum();
				if (num1 > num2)
				{
					return -1;
				} else if (num1 < num2)
				{
					return 1;
				} else
				{
					return 0;
				}
			case 2:
				int pm1 = lhs.getPm();
				int pm2 = rhs.getPm();
				if (pm1 > pm2)
				{
					return -1;
				} else if (pm1 < pm2)
				{
					return 1;
				} else
				{
					return 0;
				}
			default:
				break;
			}
		} catch (Exception e)
		{
			// TODO: handle exception
		}
		return 0;
	}

}
